package com.chis.jxc;

import com.chis.jmdatatimer.comm.TxMgmtModule;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class MysqlThread extends Thread{

    private static TxMgmtModule txMgmtModule;
    private String tablename;

    public MysqlThread(String tablename) {
        this.tablename = tablename;
    }

    static {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"spring.xml"});
        context.start();
        txMgmtModule = (TxMgmtModule) context.getBean("TxMgmtModule");
    }

    @Override
    public void run() {
        Long l1 = System.currentTimeMillis();
        try {
            List<String> list = txMgmtModule.findKc(tablename);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(" 本次耗时："+(System.currentTimeMillis()-l1));
    }

    public static void main(String[] args) {



        try {
            for(int i = 1 ; i <= 9 ; i++){
                MysqlThread threadRuning = new MysqlThread("td_jxc_stmtzx_20200"+i);
                threadRuning.start();
            }

        } catch (Exception e){
            e.printStackTrace();
        }

        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }

}
